.class Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;
.super Ljava/lang/Object;
.source "NewsImageViewer.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/netease/newsreader/view/NewsImageViewer;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "LoadingImage"
.end annotation


# instance fields
.field private mBitmap:Ljava/lang/ref/WeakReference;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ref/WeakReference",
            "<",
            "Landroid/graphics/Bitmap;",
            ">;"
        }
    .end annotation
.end field

.field private mContext:Landroid/content/Context;

.field private mPhotoInfo:Lcom/netease/newsreader/bean/PhotoInfo;

.field private mRunning:Z

.field private mTag:Ljava/lang/Object;

.field final synthetic this$0:Lcom/netease/newsreader/view/NewsImageViewer;


# direct methods
.method public constructor <init>(Lcom/netease/newsreader/view/NewsImageViewer;Lcom/netease/newsreader/bean/PhotoInfo;)V
    .locals 1
    .parameter
    .parameter "photoInfo"

    .prologue
    .line 127
    iput-object p1, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->this$0:Lcom/netease/newsreader/view/NewsImageViewer;

    .line 124
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 125
    iput-object p2, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mPhotoInfo:Lcom/netease/newsreader/bean/PhotoInfo;

    .line 126
    invoke-virtual {p1}, Lcom/netease/newsreader/view/NewsImageViewer;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mContext:Landroid/content/Context;

    return-void
.end method

.method static synthetic access$0(Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;Landroid/graphics/Bitmap;)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 152
    invoke-direct {p0, p1}, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->callback(Landroid/graphics/Bitmap;)V

    return-void
.end method

.method private callback(Landroid/graphics/Bitmap;)V
    .locals 2
    .parameter "bitmap"

    .prologue
    .line 153
    if-eqz p1, :cond_0

    .line 154
    new-instance v0, Ljava/lang/ref/WeakReference;

    invoke-direct {v0, p1}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V

    iput-object v0, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mBitmap:Ljava/lang/ref/WeakReference;

    .line 157
    :cond_0
    iget-object v0, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->this$0:Lcom/netease/newsreader/view/NewsImageViewer;

    iget-object v1, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mTag:Ljava/lang/Object;

    invoke-static {v0, p0, v1, p1}, Lcom/netease/newsreader/view/NewsImageViewer;->access$0(Lcom/netease/newsreader/view/NewsImageViewer;Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;Ljava/lang/Object;Landroid/graphics/Bitmap;)V

    .line 158
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mRunning:Z

    .line 159
    return-void
.end method


# virtual methods
.method public getBitmap()Landroid/graphics/Bitmap;
    .locals 6

    .prologue
    const/4 v3, 0x0

    .line 166
    const/4 v0, 0x0

    .line 169
    .local v0, bitmap:Landroid/graphics/Bitmap;
    iget-object v4, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mBitmap:Ljava/lang/ref/WeakReference;

    if-eqz v4, :cond_0

    .line 170
    iget-object v4, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mBitmap:Ljava/lang/ref/WeakReference;

    invoke-virtual {v4}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    .end local v0           #bitmap:Landroid/graphics/Bitmap;
    check-cast v0, Landroid/graphics/Bitmap;

    .line 173
    .restart local v0       #bitmap:Landroid/graphics/Bitmap;
    :cond_0
    if-eqz v0, :cond_2

    invoke-virtual {v0}, Landroid/graphics/Bitmap;->isRecycled()Z

    move-result v4

    if-nez v4, :cond_2

    move-object v3, v0

    .line 206
    :cond_1
    :goto_0
    return-object v3

    .line 177
    :cond_2
    iget-boolean v4, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mRunning:Z

    if-nez v4, :cond_1

    .line 182
    iget-object v4, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mPhotoInfo:Lcom/netease/newsreader/bean/PhotoInfo;

    if-eqz v4, :cond_1

    .line 186
    new-instance v4, Ljava/lang/StringBuilder;

    sget-object v5, Lcom/netease/newsreader/util/PicUtil;->phototempDir:Ljava/lang/String;

    invoke-static {v5}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v5, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mPhotoInfo:Lcom/netease/newsreader/bean/PhotoInfo;

    invoke-virtual {v5}, Lcom/netease/newsreader/bean/PhotoInfo;->getPhotoid()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    const-string v5, ".jpg"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 187
    .local v2, path:Ljava/lang/String;
    new-instance v1, Ljava/io/File;

    invoke-direct {v1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 188
    .local v1, file:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v4

    if-eqz v4, :cond_3

    .line 189
    invoke-static {v2}, Lcom/netease/newsreader/util/PicUtil;->fitSizeImg(Ljava/lang/String;)Landroid/graphics/Bitmap;

    move-result-object v0

    .line 192
    :cond_3
    if-eqz v0, :cond_4

    .line 193
    new-instance v3, Ljava/lang/ref/WeakReference;

    invoke-direct {v3, v0}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V

    iput-object v3, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mBitmap:Ljava/lang/ref/WeakReference;

    move-object v3, v0

    .line 194
    goto :goto_0

    .line 198
    :cond_4
    iput-object v3, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mBitmap:Ljava/lang/ref/WeakReference;

    .line 199
    const/4 v4, 0x1

    iput-boolean v4, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mRunning:Z

    .line 200
    new-instance v4, Ljava/lang/Thread;

    new-instance v5, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage$2;

    invoke-direct {v5, p0}, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage$2;-><init>(Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;)V

    invoke-direct {v4, v5}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    .line 205
    invoke-virtual {v4}, Ljava/lang/Thread;->start()V

    goto :goto_0
.end method

.method public run()V
    .locals 5

    .prologue
    .line 136
    iget-object v2, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mContext:Landroid/content/Context;

    invoke-static {v2}, Landroid/preference/PreferenceManager;->getDefaultSharedPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;

    move-result-object v1

    .line 137
    .local v1, sp:Landroid/content/SharedPreferences;
    const-string v2, "downpic"

    const/4 v3, 0x0

    invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z

    move-result v2

    iget-object v3, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mContext:Landroid/content/Context;

    invoke-static {v2, v3}, Lcom/netease/newsreader/util/Tools;->isshowimg(ZLandroid/content/Context;)Z

    move-result v2

    if-eqz v2, :cond_1

    .line 138
    iget-object v2, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mPhotoInfo:Lcom/netease/newsreader/bean/PhotoInfo;

    invoke-virtual {v2}, Lcom/netease/newsreader/bean/PhotoInfo;->getImgurl()Ljava/lang/String;

    move-result-object v2

    iget-object v3, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mContext:Landroid/content/Context;

    .line 137
    invoke-static {v2, v3}, Lcom/netease/newsreader/util/PicUtil;->getBitMapForStringURL(Ljava/lang/String;Landroid/content/Context;)Landroid/graphics/Bitmap;

    move-result-object v0

    .line 140
    .local v0, bitmap:Landroid/graphics/Bitmap;
    :goto_0
    iget-object v2, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->this$0:Lcom/netease/newsreader/view/NewsImageViewer;

    new-instance v3, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage$1;

    invoke-direct {v3, p0, v0}, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage$1;-><init>(Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;Landroid/graphics/Bitmap;)V

    invoke-virtual {v2, v3}, Lcom/netease/newsreader/view/NewsImageViewer;->post(Ljava/lang/Runnable;)Z

    .line 147
    if-eqz v0, :cond_0

    .line 148
    sget-object v2, Lcom/netease/newsreader/util/PicUtil;->phototempDir:Ljava/lang/String;

    new-instance v3, Ljava/lang/StringBuilder;

    iget-object v4, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mPhotoInfo:Lcom/netease/newsreader/bean/PhotoInfo;

    invoke-virtual {v4}, Lcom/netease/newsreader/bean/PhotoInfo;->getPhotoid()Ljava/lang/String;

    move-result-object v4

    invoke-static {v4}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v4, ".jpg"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3, v0}, Lcom/netease/newsreader/util/PicUtil;->saveMyBitmap(Ljava/lang/String;Ljava/lang/String;Landroid/graphics/Bitmap;)Z

    .line 150
    :cond_0
    return-void

    .line 138
    .end local v0           #bitmap:Landroid/graphics/Bitmap;
    :cond_1
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public setTag(Ljava/lang/Object;)V
    .locals 0
    .parameter "tag"

    .prologue
    .line 162
    iput-object p1, p0, Lcom/netease/newsreader/view/NewsImageViewer$LoadingImage;->mTag:Ljava/lang/Object;

    .line 163
    return-void
.end method
